<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>科研教改工作量</title>
    <!-- 引入element-ui样式 -->
    <link rel="stylesheet" href="../../../plugins/element-ui/index.css">

</head>
<body>

<div id="app">
    <el-container style="height: 800px; border: 1px solid #eee">
        <el-container>
            <div style="width: 100%;position: relative">

                <div style=";margin-bottom: 50px;margin-top: 20px">

                </div>

                <el-table   size="medium" current-row-key="id"  :data="dataList" stripe highlight-current-row>
                    <el-table-column type="index" align="center" label="序号"></el-table-column>
                    <el-table-column prop="jobNumber" label="工号" align="center"></el-table-column>
                    <el-table-column prop="major" label="专业" align="center"></el-table-column>
                    <el-table-column prop="time" label="提交时间" align="center"></el-table-column>
                    <el-table-column prop="type" label="类型" align="center"></el-table-column>

<!--                    <el-table-column prop="studyHour" label="计划学时" align="center"></el-table-column>-->
<!--                    <el-table-column prop="studentNumber" label="学生数量" align="center"></el-table-column>-->
<!--                    <el-table-column prop="quantity" label="次数" align="center"></el-table-column>-->

                    <el-table-column prop="file" label="附件" align="center"></el-table-column>
                    <el-table-column prop="level" label="等级" align="center"></el-table-column>

<!--                    <el-table-column prop="status" label="状态" align="center">-->
<!--                        <template slot-scope="props">-->
<!--                            <el-tag v-if="props.row.status == 'true'" :type="'success'" disable-transitions>通过</el-tag>-->
<!--                            <el-tag v-else-if="props.row.status == 'false'" :type="'primary'" disable-transitions>未通过</el-tag>-->
<!--                        </template>-->
<!--                    </el-table-column>-->

                    <el-table-column prop="grade" label="评分" align="center"></el-table-column>
                    <el-table-column label="操作" width="200" align="center">
                        <template slot-scope="scope">
                            <el-button type="danger"  size="mini" @click="gradeDialogShow(scope.row)">评分</el-button>
                            <el-button type="primary" size="mini" @click="down(scope.row)">下载</el-button>
                        </template>
                    </el-table-column>
                </el-table>

                <!--分页组件-->
                <el-pagination
                        class="pagination"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>


                <!--2.评分 论文工作量弹框-->
                <el-dialog title="评分" style="height: 650px"  :visible.sync="dialog_update">
                    <el-form :model="formData_update" :rules="rules" ref="formData_update" label-width="100px" class="demo-formData_update">
                        <el-form-item  label="公式选项：" prop="option">
                            <template>
                                <el-select v-model="formData_update.option" placeholder="请选择">
                                    <el-option
                                            v-for="item in options1"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>

                        <!--                        <el-form-item  label="评分：" prop="grade">-->
                        <!--                            <template>-->
                        <!--                                <el-input-number v-model="formData_update.grade" @change="handleChange" :min="1" :max="10" label="评分"></el-input-number>-->
                        <!--                            </template>-->
                        <!--                        </el-form-item>-->


                        <el-form-item>
                            <el-button type="primary" @click="sureGrade">确定</el-button>
                            <el-button @click="center">取消</el-button>
                        </el-form-item>
                    </el-form>
                </el-dialog>

            </div>
        </el-container>
    </el-container>


</div>


<script src="../../../plugins/vue/vue.js"></script>

<!-- 引入element-ui组件库 -->
<script src="../../../plugins/element-ui/index.js"></script>

<!-- 引入axios -->
<script src="../../../plugins/axios/axios.min.js"></script>

<script>

    new Vue({
        data:{

            adminInfo:{}, //当前用户信息


            //显示的数据
            dataList:[],

            //element-ui分页插件
            pagination: {//分页相关模型数据 1
                currentPage: 1,//当前页码1
                pageSize:5,//每页显示的记录数1
                total:0,//总记录数1
            },

            dialog_update:false,

            formData_update:{
                file:"",
            },
            options1: [{
                value: '国家级',
                label: '国家级'
            },{
                value: '省级',
                label: '省级'

            },{
                value: '市级',
                label: '市级'

            },],

        },
        el:'#app',    //element
        created() {
            const adminInfo = window.localStorage.getItem('admin')
            console.log("adminInfo1:::"+adminInfo)
            if (adminInfo) {
                this.adminInfo = JSON.parse(adminInfo)
            }
            console.log("adminInfo2:::"+adminInfo)

            this.getAll();

        },
        methods:{

            getAll(){

                axios.get("/scientifics/getPageScientific/"+this.pagination.currentPage+"/"+this.pagination.pageSize).then((res)=>{
                    console.log(res)
                    this.dataList=res.data.data.records
                    this.pagination.total=res.data.data.total

                })
            },

            //切换页码
            handleCurrentChange(currentPage) {
                console.log("切换页码:")
                this.pagination.currentPage=currentPage;
                console.log(currentPage)
                this.getAll();
            },


            //评分框
            gradeDialogShow(row){
                this.formData_update=row
                this.formData_update.grade=""

                this.dialog_update=true
            },

            //确定评分
            sureGrade(){
                if (this.formData_update.option=="国家级"){
                    this.formData_update.grade= 300
                }else if (this.formData_update.option=="省级"){
                    this.formData_update.grade=200
                }else if (this.formData_update.option=="市级"){
                    this.formData_update.grade= 100
                }
                axios.put("/scientifics/updateScientific",this.formData_update).then((res)=>{
                    if (res.data.code){
                        this.$message.success("评分成功")
                    }else{
                        this.$message.error("评分失败")
                    }
                }).finally(()=>{
                    this.getAll();
                    this.dialog_update=false;
                })
            },

            center() {
                this.dialog_update=false
                this.dialog_update.grade="未评定"
                // this.dialog_add=false
                this.$message.info("取消操作")
            },



            //下载
            down(row){
                console.log("row")
                console.log(row)
                if (row.file!=null){
                    window.location.href="http://localhost:8080/files/downloadFile2?name="+row.file
                }else {
                    this.$message.error("没有附件下载")
                }
            },
        }
    })

</script>
</body>
</html>




